import { makeRequiredRule } from '../../../utils'

const label = '头像'
const name = 'profile'
let i = 1
const uniqueId = () => `${name}${i++}`

export default {
  label,
  name,
  rule() {
    return {
      type: 'upload',
      field: uniqueId(),
      title: label,
      value: '',
      props: {
        uploadType: 'image',
        multiple: false,
        limit: 1,
        action: 'https://match.zh24.shop/common/upload/oss',
        accept: 'image/*',
        format: ['jpg', 'jpeg', 'png'],
        onSuccess(res, file) {
          if (res.code === 0) {
            file.url = res.data.url
          }
        }
      }
    }
  },
  props() {
    return [
      {
        type: 'input',
        field: 'formCreateTitle',
        value: label,
        title: '字段名称'
      },
      makeRequiredRule()
    ]
  }
}
